﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="PublishManage.aspx.cs" Inherits="Whir_System_Module_Publish_PublishManage" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

    <script language="javascript" type="text/javascript">
        if (top.location == self.location) { 
            alert('禁止访问子栏目页！将跳转到默认页面');
            top.location='../../Default.aspx';
        } 
    </script>

    <link href="../../Skin/Default/Css/main.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="<%= ResolveUrl("../../Js/extjs2/resources/css/ext-all.css") %>" />
    <link rel="stylesheet" type="text/css" href="<%= ResolveUrl("../../Js/extjs2/resources/css/xtheme-gray.css") %>" />

    <script type="text/javascript" src="<%= ResolveUrl("../../Js/extjs2/adapter/ext/ext-base.js") %>"></script>

    <script type="text/javascript" language="javascript" src="<%= ResolveUrl("../../Js/extjs2/ext-all.js") %>"></script>

    <script type="text/javascript">
        var pbar;
        var columnId,length=0;
        var num=0;
        var iframe;
        var msg;
        Ext.onReady(function(){
            pbar = new Ext.ProgressBar({renderTo:'bar',width:600,text:'生成进度'});
            show(false);
            iframe = document.getElementById("MainIFrame1");
            msg = document.getElementById("txtmsg");
        });
        
        function reset(){
            num=0;
            length=0;            
        }        
        
        function show(bolshow){
            if(bolshow){
                pbar.show();
                Ext.get("txtmsg").show();
            }
            else
            {
                pbar.hide();
                Ext.get("txtmsg").hide();
            }
        }
        
        //生成选中栏目
        function createColumn(){
            pbar.reset();
            msg.innerHTML = "";
            show(true);
            var id = document.getElementById("txtChkValue").value;
            if(id=="")
            {
                alert("请选择需要生成的栏目！");
                return;
            }
            length = id.split(",").length;        
            
            iframe.src='publish.aspx?columnID='+document.getElementById("txtChkValue").value+getdate();
        }
        
        //生成全部栏目
        function createColumnAll(){
            pbar.reset();
            msg.innerHTML = "";
            show(true);            
            
            iframe.src='publish.aspx?columnID=-1';//+getdate();
        }        

        
        //更新进度条
        function UpdateProgressBar(text,url,bol)
        {
            num++;            
            if(bol)
            {
                if(url!=""){
                    msg.innerHTML += text+"<a href='../../UserControls/Common/go.ashx?Action=PreviewItem&columnID="+url+"' target='_blank'>预览<br />";
                }
                else{
                    msg.innerHTML += text+"<br />";
                }
            }
            else
            {                
                msg.innerHTML += text;
                pbar.updateProgress(num/length, text);
            }
            msg.scrollTop = msg.scrollHeight;
        }
        
        //获取时间
        function getdate()
        {
            var str = "";
            var d1 = document.getElementById("EzCalender1");
            var d2 = document.getElementById("EzCalender2");
            if(d1.value!=""&&d2.value!="")
            {
                str = "&bDate="+d1.value+"&eDate="+d2.value;
            }
            return str;
        }
        
        //设置生成时间
        function setTime(s)
        {
            msg.innerHTML += "<br /><br />--------------------<br />";
            msg.innerHTML += "程序生成时间: "+s+" 秒";
            msg.scrollTop = msg.scrollHeight;
        }
        
        //显示/隐藏生成进度
        function changeState(){
            var id = document.getElementById('txtmsg');
            if(id.style.display == "none")
                Ext.get("txtmsg").show();
            else
                Ext.get("txtmsg").hide();
        }
    </script>

</head>
<body style="overflow: scroll; overflow-x: hidden">
    <form id="form1" runat="server">
        <table width="99%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td class="form_title">发布栏目&nbsp;</td>
            </tr>
            <tr>
                <td>
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td valign="top" width="300" class="form_td">
                                <div id="tree-div" style="overflow: auto; height: 430px; border: 0px">
                                </div>
                            </td>
                            <td valign="top" class="form_td">
                                <div id="msg">
                                </div>
                                <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#DADADA">
                                    <tr>
                                        <td height="50" width="100" align="left" class="form_tdText" rowspan="2">
                                            按信息发布时间段
                                        </td>
                                        <td class="form_td">
                                            从&nbsp;<input id="EzCalender1" class="Wdate" type="text" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'EzCalender2\')||\'2020-10-01\'}'})" runat="server" />
                                            &nbsp;到&nbsp;
                                            <input id="EzCalender2" class="Wdate" type="text" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'EzCalender1\')}',maxDate:'2020-10-01'})" runat="server" />&nbsp;
                                            </td>
                                    </tr>                                    
                                    <td class="form_td"><input type="button" class="btn_default2" value="按时间段生成" onclick="createColumn();" /></td>
                                    <tr>
                                        <td class="form_tdText">一键生成</td>
                                        <td class="form_td">
                                            <input type="button" class="btn_default2" value="生成选择的栏目" onclick="createColumn();" />
                                            <input type="button" class="btn_default2" value="静态生成整站" onclick="createColumnAll();" />
                                        </td>
                                    </tr>                                    
                                </table>                                
                                <div id="bar">
                                </div>
                                <div id="txtmsg" style="background-color:White;padding-left:10px;WIDTH:600px;HEIGHT:370px;OVERFLOW-Y:auto;SCROLLBAR-FACE-COLOR:#ffffff;SCROLLBAR-HIGHLIGHT-COLOR:#ffffff;OVERFLOW:auto;SCROLLBAR-SHADOW-COLOR:#919192;SCROLLBAR-3DLIGHT-COLOR:#ffffff;LINE-HEIGHT:120%;SCROLLBAR-ARROW-COLOR:#919192;SCROLLBAR-TRACK-COLOR:#ffffff;SCROLLBAR-DARKSHADOW-COLOR:#ffffff;LETTER-SPACING:1pt;TEXT-ALIGN:left"></div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" align="center" class="form_td">
                                <asp:TextBox ID="txtChkValue" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </form>

    <script type="text/javascript" language="javascript">

var tree = null;
var txtChkValue = document.getElementById("txtChkValue");
Ext.onReady(function(){

    Ext.BLANK_IMAGE_URL = "../../Js/extjs2/resources/images/default/s.gif"
    // shorthand
    var Tree = Ext.tree;
    
    tree = new Tree.TreePanel({
        el:'tree-div',
        autoScroll:true,
        animate:true,
        enableDD:false,
        containerScroll: true, 
        onlyLeafCheckable: false,//对树所有结点都可选 
        loader: new Tree.TreeLoader({
            dataUrl:'../../getTreeData.aspx?chk=1'            
        }),
        margins:'15,15,15,15',
        border:true        
    });
    
    tree.on('checkchange', function(node, checked) {
                    node.expand();
                    node.attributes.checked = checked;
                    var parentNode = node.parentNode;
                    if(checked){
                        if(parentNode!=null&&parentNode.id!='source'){
                            //如果是选中,把父节点保持选中状态
                            parentNode.ui.toggleCheck(true);
                            parentNode.attributes.checked = true;
                        }
                    }else{
                        //如果所有子节点都没选中，取消根节点选中状态
                        if(parentNode!=null&&parentNode.id!='source'){
                            var chk = false;
                            parentNode.eachChild(function(child) {
                                if(child.attributes.checked)chk=true;
                            });
                            parentNode.ui.toggleCheck(chk);
                            parentNode.attributes.checked = chk;
                        }
                    }
                    node.eachChild(function(child) {
                        child.ui.toggleCheck(checked);
                        child.attributes.checked = checked;
                        child.fireEvent('checkchange', child, checked);
                    });
                    txtChkValue.value = tree.getChecked('id');
                }, tree);

    // set the root node
    var root = new Tree.AsyncTreeNode({
        text: '请选择要生成的栏目',
        draggable:false,
        id:'source'
    });
    tree.setRootNode(root);

    // render the tree
    tree.render();
    root.expand();
});

    </script>

    <iframe id="MainIFrame1" name="MainIFrame1" frameborder="0" width="100%" height="500"
        src="about:blank" style="display: none;"></iframe>
</body>
</html>

<script language="javascript" src="../../UserControls/My97DatePicker/WdatePicker.js"
    type="text/javascript"></script>

